include(CommonModularInterface)
include_directories(${LUA_INCLUDE_DIRS})

SET(LUA_MODULAR_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
GENERATE_MODULAR_TARGET(lua ${CMAKE_CURRENT_SOURCE_DIR} "${LUA_LDFLAGS}")

IF (NOT LIB_INSTALL_DIR)
	SET(LIB_INSTALL_DIR lib)
ENDIF()

STRING(REGEX REPLACE "([0-9]*.[0-9]*).[0-9]*" "${LIB_INSTALL_DIR}/lua/\\1" LUA_EXTENSION_DIR ${LUA_VERSION})

INSTALL(TARGETS lua_modular
	LIBRARY DESTINATION ${LUA_EXTENSION_DIR}
	COMPONENT lua)
